home *** CD-ROM | disk | FTP | other *** search
- property mySprite, myFixedPoint
-
- on beginSprite me
- mySprite = sprite(me.spriteNum)
- theMember = mySprite.member
- memberType = theMember.type
- stageWidth = the stageRight - the stageLeft
- stageHeight = the stageBottom - the stageTop
- myFixedPoint = point(stageWidth, stageHeight) / 2
- end
-
- on prepareFrame me
- slope = myFixedPoint - mySprite.loc
- angle = GetAngle(me, slope)
- if mySprite.rotation <> angle then
- mySprite.rotation = angle
- end if
- end
-
- on GetAngle me, slope
- dH = slope[1]
- dV = slope[2]
- if dH then
- slope = float(dV) / dH
- angle = atan(slope)
- if dH < 0 then
- angle = angle + PI
- end if
- else
- if dV > 0 then
- angle = PI / 2
- else
- if dV < 0 then
- angle = 3 * PI / 2
- else
- angle = 0
- end if
- end if
- end if
- angle = angle * 180 / PI
- return angle
- end
-
- on getMag me, slope
- return sqrt(power(slope[1], 2) + power(slope[2], 2))
- end
-